package controller;

import com.alibaba.fastjson.JSON;
import dao.StatisticsDao;
import dao.imp.IStatisticsDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @program: personnel_management_system
 * @description: Statistics Cont
 * @author: Mr.Sun
 * @create: 2020-05-30 10:14
 **/
@WebServlet("/statistics")
public class StatisticsController extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        IStatisticsDao sdao = new StatisticsDao();
        resp.setContentType("text/json;charset=UTF-8");
        resp.setCharacterEncoding("UTF-8");
        PrintWriter out = resp.getWriter();
        try {
            System.out.println(sdao.select());
            out.println(JSON.toJSONString(sdao.select()));
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            out.flush();
            out.close();
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }
}
